<!DOCTYPE html>
<html lang="zh-CN"  xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>netty ceshi</title>
    <script type="text/javascript">
        var socket;
        if(!window.WebSocket){
            window.WebSocket = window.MozWebSocket;
        }
        if(window.WebSocket){
            socket = new WebSocket("ws://localhost:8888/ws");
            socket.onmessage = function(event){
                var ta = document.getElementById('responseText');
                ta.value += event.data+"\r\n";
            };
            socket.onopen = function(event){
                var ta = document.getElementById('responseText');
                ta.value = "netty server resp"+"\r\n";

            };
            socket.onclose = function(event){
                var ta = document.getElementById('responseText');
                ta.value = "";
                ta.value = "WebSocket close"+"\r\n";
            };
        }else{
            alert("您的浏览器不支持WebSocket协议...");
        }
        function send(message){
            if(!window.WebSocket){return;}
            if(socket.readyState == WebSocket.OPEN){
                socket.send(message);
            }else{
                alert("WebSocket connection fail...");
            }

        }

    </script>
</head>
<body>
<form onSubmit="return false;">
    <input type="text" name="message" value="input conn message" /> <br />
    <br /> <input type="button" value="send  WebSocket req message"
                  onClick="send(this.form.message.value)" />
    <hr color="blue" />
    <h3>netty server response message</h3>
    <textarea id="responseText" style="width: 1024px;height: 300px;"></textarea>
</form>
</body>
</html>
